#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2024-05-17 15:34
# @Author  : nedncs
# @File    : FilePaths.py
# @Description : 起始加载文件
from pathlib import Path
import os, sys


class FilePaths:
    DATA_DIR = 'data'
    LOG_DIR = 'logs'
    CONFIG_FILE = 'config.toml'


# 基本信息
POJECT_NAME = 'python-ldap-admin'
DEBUG_MODE = None
LOG_LEVEL = ''
LOG_HANDLER = None
# 命令行解析
COMMAND_LINE = sys.argv
if '-m' in COMMAND_LINE:
    ind = COMMAND_LINE.index('-m')
    DEBUG_MODE = True if COMMAND_LINE[ind] != 'debug' else False
    del ind
    pass
if '-l' in COMMAND_LINE:
    ind = COMMAND_LINE.index('-l')
    LOG_LEVEL = 'info' if COMMAND_LINE[ind] in ['info', 'debug', 'waring', 'error'] else COMMAND_LINE[ind + 1]
    del ind
    pass

# 环境获取
RUN_DIR = Path(os.getcwd())
BASE_DIR = Path(RUN_DIR)

# 环境赋值
LOG_DIR = Path(BASE_DIR) / FilePaths.LOG_DIR
LOG_FILE = Path(LOG_DIR) / POJECT_NAME
CONFIG_FILE = Path(BASE_DIR) / FilePaths.DATA_DIR / FilePaths.CONFIG_FILE
DATA_DIR = Path(BASE_DIR) / FilePaths.DATA_DIR
# 创建文件夹
if not LOG_DIR.exists():
    LOG_DIR.mkdir()
if not DATA_DIR.exists():
    DATA_DIR.mkdir()
